import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';

const Timestamp = new Date().getTime();//随机时间戳

// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  build: {
    sourcemap: false, // 输出.map文件,默认是false
    rollupOptions: {
      output: {
        chunkFileNames: `static/js/[name].[hash]${Timestamp}.js`,
        entryFileNames: `static/js/[name].[hash]${Timestamp}.js`,
        assetFileNames: `static/[ext]/[name].[hash]${Timestamp}.[ext]`,
      },
    }
  },
  plugins: [
    vue(),
    Components({
      resolvers: [
        AntDesignVueResolver({
          importStyle: false, // css in js
        }),
      ],
    }),
   
  ],
  server: {
    host: '0.0.0.0',
    port: 8080,

    proxy: {
     
      '/jiancai': {
        target: 'https://jiancai.luoluqi.top',
        // target: 'http://localhost:35001',
        
        changeOrigin: true,
      },

      '/jiancai/ws': {
        target: 'wss://jiancai.luoluqi.top',
        // target: 'ws://localhost:35001',
        ws: true, 
        changeOrigin: true,
      },
      
    }
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
